import request from "@/utils/request";

const COINS_BASE_URL = "/platform/coupon/storage";

const listApi = {
  // 代金券配置接口
  add(data: Object) {
    return request({
      url: `${COINS_BASE_URL}/add`,
      method: "post",
      data,
    });
  },
  list(data: Object) {
    return request({
      url: `${COINS_BASE_URL}` + "/page",
      method: "get",
      params: data,
    });
  },
  getShopList(keyword: string) {
    return request({
      url: `${COINS_BASE_URL}` + "/getSupportedMerchant",
      method: "get",
      params: {
        keyword: keyword,
      },
    });
  },
  detail(id: number) {
    return request({
      url: `${COINS_BASE_URL}` + "/getDetailById",
      method: "get",
      params: {
        id,
      },
    });
  },
  update(data: Object) {
    return request({
      url: `${COINS_BASE_URL}/updateById`,
      method: "post",
      data,
    });
  },
  delCoupon(data: object) {
    return request({
      url: `${COINS_BASE_URL}/deleteByIds`,
      method: "post",
      data,
    });
  },
  changeStatus(data: object) {
    return request({
      url: `${COINS_BASE_URL}/changeStatus`,
      method: "post",
      data,
    });
  },
  changeEnable(data: object) {
    return request({
      url: `${COINS_BASE_URL}/changeEnable`,
      method: "post",
      data,
    });
  },
  // 代金券列表页面接口
  pages(data: object) {
    return request({
      url: `/platform/coupon/page`,
      method: "get",
      params: data,
    });
  },
  couponDetail(id: number) {
    return request({
      url: `/platform/coupon/getDetailById`,
      method: "get",
      params: {
        id: id,
      },
    });
  },

  //代金券结算页面接口
  orderList(params: Object) {
    return request({
      url: `/platform/coupon/order/page`,
      method: "get",
      params: params,
    });
  },

  orderDetail(id: number) {
    return request({
      url: `/platform/coupon/order/getDetailById`,
      method: "get",
      params: {
        id: id,
      },
    });
  },
  audit(data: Object) {
    return request({
      url: `/platform/coupon/order/audit`,
      method: "post",
      data,
    });
  },
};

export default listApi;
